<template>
	<view>
	<cu-custom :isBack="true">
		<block slot="backText"></block>
		<block slot="content">{{corpCode}}-货位存量查询</block>
	</cu-custom>
	<view class="cu-bar bg-white search fixed indexes" :style="[{top:CustomBar + 'px'}]">
		<view class="search-form round" >
			<text class="cuIcon-search"></text>
			<!-- <input @confirm="sub" v-model="asnId" :focus="true" ></input> -->
			<input @confirm="data()" v-model="asnId" type="text" placeholder="输入搜索的关键词" focus></input>
		</view>
		<view>
			<checkbox-group class="block" @change="checkboxChange">
				<checkbox :class="checked?'checked':''" :checked="checked" value="A">精准</checkbox>
			</checkbox-group>
		</view>
		<view class="action" @click="toScan">
			<text class="cuIcon-scan" style="font-size: 56rpx;"></text>
		</view>
	</view>
		<view  style="font-size: 16px; background-color: #fff;height: 100%;margin-top: 12%;">
			<form>
				<view class="scroll-view-item" >
					<view class="cu-form-group">
						<view class="title">存货编码：</view>
						<input v-model="infoData.viewCode" placeholder="暂无数据" name="input" disabled="false"></input>
					</view>
					<view class="cu-form-group">
						<view class="title">存货名称：</view>
						<input v-model="infoData.cinvname" placeholder="暂无数据" name="input" disabled="false"></input>
					</view>
					<view>
						<v-table :columns="columns" :list="list" selection="single"></v-table>
					</view>
					<view class="cu-form-group" style="margin-top: 20px;">
						<view class="title">汇总：</view>
						<input v-model="num" placeholder="0" name="input" disabled="false"></input>
					</view>
				</view>
			</form>
			</view>
	</view>
</template>

<script>
	import vTable from "@/components/no-bad-table/table.vue";
	import {
		mapState
	} from 'vuex';
	export default {
		components: {
			vTable
		},
		data() {
			return {
				checked:false,
				cposcode:'',
				areaCode:'',
				layerList:'',
				infoData:'',
				modalName: null,
				unlockNum:0,
				rowname:'',
				list:[],
				checkbox: [],
				CustomBar: this.CustomBar, //滚动定位用
				asnId:'',
				num:0,
				columns: [
					// {
					// 	title: '序号',
					// 	key:'index',
					// 	$width:'50px',
					// },
					{
						title: '现存量',
						key: 'iquantity',
					},
					{
						title: '货位名称',
						key: 'cposname'
					},
					{
						title: '批次',
						key: 'cbatch'
					},
					{
						title: '仓库',
						key: 'cwhname'
					},
				],
			}
		},
		mounted() {
		//      this.timer = setInterval(this.get, 1000);
		},
		computed: {
			...mapState(['hasLogin', 'userInfo', 'auditlist', 'corpCode','global']),
		},
		onLoad(data) {
			//this.cposcode=data.cposcode;
		//	this.asnId = 'sc_102_1000038945_102';
			//this.data();
			//this.listData();
//			this.loadData();
		},
		methods: {
			allCheckbox(){
				if(this.checkbox.indexOf(0)==-1){
					this.checkbox=[];
				for(var i=0;i<this.collist.length;i++){
					this.checkbox.push(i)
				}
				return ;
				}
				this.checkbox=[];
			},
			CheckboxChange(e) {
				var items = this.checkbox;
				let	values = e.detail.value;
				this.checkbox=values;
			},
			/**
			 * 判断登录
			 */
			ishasLogin(){
				if(!this.hasLogin){
					uni.navigateTo({
						url: '/pages/public/login'
					})
					return;
				} 
			},
			showModal(e) {
				this.modalName = e.currentTarget.dataset.target
			},
			hideModal(e) {
				this.modalName = null
			},
			showModalsl(){
				this.modalName = "DialogModalsl";
			},
			toScan() {
				uni.scanCode({
					onlyFromCamera: true,
					success: function(res) {
						var rdata = res.result;
						this.asnId = rdata;
						setTimeout(function(){
							this.data();
						}.bind(this),100);
						
					}.bind(this)
				});
			},
			//列表锁定货位列表
			listData(){
				var data = this.cposcode+'_'+this.checked;
				uni.request({
					url:this.serverURL_a+'/wh/whLockRecord/listData',
					data:{
						'basPos.cposcode':data,
						pageNo:1,
						pageSize:100,
						__sid:this.userInfo.sessionid
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
					},
					method: 'POST',
					success:function(res){
						var  resData = res.data;
						console.log(resData)
						this.collist=resData.list;
						
					}.bind(this),
					fail: function() {
						uni.hideLoading()
						this.$api.msg('无法连接服务，请联系管理');
						this.isReC = false;
						return;
					}.bind(this)
				})
			
			},
			checkboxChange(){
				this.checked = !this.checked;
			},
			//列锁定详情
			data(){
				this.infoData='';
				this.list=[];
				this.num=0;
				uni.request({
					// url:this.serverURL_a+'/bas/basInventory/findMapCinvcode?__ajax=json',
					// url:this.serverURL_a+'/barcode/decode/getInvInfo?__ajax=json',
					url:this.serverURL_a+'/barcode/decode/findInvPosSum',
					data:{
						// hw : this.asnId+'_'+this.checked,
						__sid:this.userInfo.sessionid,
						// barCode: this.asnId+'_'+this.checked,
						// bneedStore: '1',
						// bmustAcct:'0',
						barCode:this.asnId,
						isEq:this.checked,
						
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
					},
					method: 'POST',
					success:function(data){
						this.asnId = '';
						var res = data.data;
						if(data.statusCode!="200"){
							uni.showModal({
								content: request.message,
								showCancel:false,
							});
							this.ishow = false;
							return;
						}
						if(res.result=="false"){
							uni.showModal({
								  content: res.message,
								  showCancel:false,
								 })
							return false;
						}
						this.$api.msg(res.message);
						this.infoData=res.data.basInv;
						this.list=res.data.posSumList
						for(var i=0;i<this.list.length;i++){
							this.num=this.num+this.list[i].iquantity;
						}
					}.bind(this),
					fail: function() {
						uni.hideLoading()
						this.$api.msg('无法连接服务，请联系管理');
						this.isReC = false;
						return;
					}.bind(this)
				})
			},
		}
	}
</script>

<style>
	.uni-fab-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		justify-content: center;
		position: absolute;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
	}
	
	.uni-padding-wrap {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}
	
	.word-btn {
		width: 250px;
	}
	.font_color-text{
		color: #FFF;
	}
	.fontAlgen{
		text-align: center;
		padding: 5px;
	}
	.bag-corol{
		color: #FFF;
		background-color: #A1DCC1;
	}
	.bag-corol2{
		color: #FFF;
		background-color: #07C160;
	}
	.bag-corhui{
		color: #FFF;
		background-color: #CCCCCC;
	}
	.bag-corol3{
		color: #FFF;
		background-color: #0000FF;
	}
	.fontSort{
		color: #0000FF;
		width: 5%;height: 5%;
		margin-right: 3px;
		float: left;
		font-size: 14px;
		margin-top: 3.5%;
	}
	.fontWith2{
		margin-left: 10%;
	}
	.fontSold{
		border-style: solid solid;
	}
	
	.fontWith{
		width: 100%;height: 100%;
	}
	.fontY{
		float: right;
		margin-top: 1.5%;
	}
	
	
	/* 底部操作菜单 */
	.page-bottom{
		position:fixed;
		right: 3%;
		bottom:30upx;
		z-index: 95;
		display: flex;
		justify-content: center;
		align-items: center;
		background: rgba(255,255,255,.9);
		box-shadow: 0 0 20upx 0 rgba(0,0,0,.5);
		border-radius: 16upx;
	}

	.tbale{
		min-width: 362px!important;
	}
</style>
 